'use strict';

const db = uniCloud.database();
exports.main = async (event, context) => {
	//event为客户端上传的参数

	console.log('event : ', event)
	// const dbCmd=db.command;
	const userId = event.userId;
	let dbRes;
	dbRes = await db.collection('orders').where({
		userId,
		status: "已完成"
	}).orderBy("created_at", "desc").get();
	//通过id降序获取,后期用创建时间来排序也可以...
	return dbRes;
};